package jude.java.framework.ajax;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.directwebremoting.WebContextFactory;

public class AjaxTemplate {
	
	public ServletContext getServletContext(){
		return WebContextFactory.get().getServletContext();
	}
	
	public HttpServletRequest getRequest(){
		return WebContextFactory.get().getHttpServletRequest();
	}
	
	public <T> T execute(AjaxCallback<T> callback) {
		return callback == null ? null : callback.executeInAjax();
	}

}
